package com.example.app

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.base.SkillActionListener
import com.example.base.SkillManager
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        tv.setOnClickListener {
            handleIntent("shopping")
        }
    }

    private fun handleIntent(intent: String) {
        var clazz = App.skillMap[intent]
        var skillManager = clazz?.newInstance() as? SkillManager
        skillManager?.action(null, object : SkillActionListener {
            override fun onSuccess(res: String?) {
                tv.text = res
            }

            override fun onFailed(msg: String?) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }

        })
    }
}
